<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <script src="js/jquery.min.js"></script>
  <script src="js/jquery.form.min.js"></script>
</head>
<body>
  <input type="file" id="file" name="file" multiple="multiple">
  <input type="button" id='btn' value="上传" />
  <script>
    $(function () {
      $('#btn').click(function () {
        var fileList = $('#file')[0].files
        var fileListLength = fileList.length
        if (fileListLength > 0) {
          for (var i = 0, len = fileList.length; i < len; i++) {
            let formData = new FormData();
            formData.append('file', fileList[i]);
            $.ajax({
              url: '/comm-file-server/file/upload?sysCode=project&businessId=123&businessNode=1',
              type: 'post',
              data: formData,
              processData: false,
              contentType: false,
              success: function (res, statusText, headers) {
                if (res.success) {
                	window.location.href="/comm-file-server/filelist.html";
                	alert('文件上传成功');
                } else {
                  alert(res.errorMsg);
                  console.log(res);
                }
              }
            })
          }
        } else {
          alert("请选择文件！")
        }
      })
    })


  </script>
</body>

</html>